<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/view/system/common/head.jsp"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<body>
	<form id="menuAddFrom" name="menuAddFrom" action="">
		<div id="p" class="easyui-panel" title="添加菜单"  fit="true" style="padding: 10px; background: #fafafa;text-align:center;">
			<fieldset>
				<legend style="color: blue;font-size:1.5" >
					上级菜单信息
				</legend>
				<table class="infoTable">
					<tr>
						<td style="width:25%;text-align:right" >
							<input type="hidden" name="parentid" value="${parentMenu.id}" />
							<input type="hidden" name="level" value="${parentMenu.level+1}" />
							<input type="hidden" name="type" value="${parentMenu.level==4?2:1}" />
							上级菜单名称 ：
						</td>
						<td  style="width:60%;"  class="redText">
							${parentMenu.name}
						</td>
					</tr>
					<tr>
						<td style="width:25%;text-align:right" >
							上级菜单描述 ：
						</td>
						<td style="width:60%;"  class="redText">
							${parentMenu.descr}
						</td>
					</tr>
				</table>
			</fieldset>
			<fieldset>
				<legend style="color: blue;" >
					子菜单信息
				</legend>
				<table style="width:98%;border:0;border-collapse:collapse;border-spacing:1px;padding:4px;">
					<tr>
						<td style="width:25%;text-align:right" >
							菜单类型 ：
						</td>
						<td style="width:60%;" class="redText">
							${parentMenu.level==4?'按钮':'菜单'}
						</td>
					</tr>
					<tr>
						<td style="width:25%;text-align:right" >
							菜单名称
							<span class="colrRed"> * </span>：
						</td>
						<td style="width:60%;">
							<input type="text" id="newMenu_name" name="name"
								class="easyui-validatebox myinput" missingMessage="请输入菜单名称"  placeholder="请输入菜单名称"
								required="true" maxlength="30"   />
						</td>
					</tr>
					<c:choose>
					<c:when test="${parentMenu.level == 4}">
					
						<tr>
							<td style="width:25%;text-align:right" >
								按钮CODE
								<span class="colrRed"> * </span>：
							</td>
							<td style="width:60%;"><!-- 	validType="remote['checkMenuCode.action','menuCode']" -->
								<input type="text" id="newMenu_url" name="url" 
									class="easyui-validatebox myinput" missingMessage="请输入按钮CODE"  placeholder="请输入按钮CODE"
								    required="true" maxlength="30" style="width: 150px;" />
							</td>
						</tr>
					</c:when>
					<c:when test="${parentMenu.level < 4}">
						<td style="width:25%;text-align:right" >
							URL地址
							<span class="colrRed"> * </span>：
						</td>
						<td style="width:60%;">
							<input type="text" id="newMenu_url" name="url" 
								class="easyui-validatebox myinput"   style="width: 150px;" />
						</td>
					
					</c:when>
					</c:choose>
					<c:choose>
					<c:when test="${parentMenu.level < 4}">
						<tr>
							<td style="width:25%;text-align:right" > 选择图片 ： </td>
							<td style="width:60%;">
							<c:forEach var="menuIcon" items="${menuIconList}">
							
									<nobr> <input type="radio" name="imgurl"
											value="${menuIcon.value}"
											style="vertical-align: sub;"
											id="ICON_${menuIcon.value}" /> <label
											for="ICON_${menuIcon.value}">
											<img  src="asserts/system/images/menu/${menuIcon.name}.gif"></img>
										</label>
									</nobr>
								
								</c:forEach>
							</td>
						</tr>
					
					</c:when>
					</c:choose>
					<tr>
						<td style="width:25%;text-align:right" >
							负责人 ：
						</td>
						<td style="width:60%;">
							<input type="text" id="newMenu_manager" name="manager"
								class="easyui-validatebox myinput" style="width: 150px;" />
						</td>
					</tr>
					<tr>
						<td style="width:25%;text-align:right" >
							描述 ：
						</td>
						<td style="width:60%;">
							<textarea class="easyui-validatebox" id="newMenu_descr"
								name="descr" validType="length[0,160]" rows="3"
								cols="40" ></textarea>
						</td>
					</tr>
				</table>
			</fieldset>
			<div style="text-align:center;">
				<br />
				<a class="easyui-linkbutton myLink" iconCls="icon-ok" onclick="submitForm()">新增</a>
				&nbsp;&nbsp;&nbsp;
				<a  class="easyui-linkbutton myLink" iconCls="icon-undo" onclick="resetFrom()">重置 </a>
			</div>
		</div>
	</form>
</body>
<script>
//重置
function resetFrom() {
	$("#menuAddFrom").form("reset");
}

//页面提交
function submitForm() {
	//判断参数是否为空
	var valid = $('#menuAddFrom').form('validate');
	if (valid) {
		var param = $('#menuAddFrom').serializeJson(true);
		$.axs("menu/doMenuAdd.action", param, 
                function(data){
			if(data.status == 1){
				$.messager.alert("提示信息",
						data.msg, 'info', function() {
				parent.$("#menuTreegrid").treegrid('reload');
				resetFrom();
				});
			}else{
				$.messager.alert("提示信息", data.msg, 'error');
			}
		});
		
	
	}
}

</script>
</html>